public class Demo42 {
    public static void main(String[] args) throws InterruptedException {
        Thread myThread=new Thread(()->{
            Thread t=Thread.currentThread();//获取到myThread线程的实例
            System.out.println(t.getName()); //获取myThread线程的名字
        });
        myThread.start(); //用线程的引用去启动线程
        myThread.join(); //让main线程去等myThread线程执行完以后再去执行
        System.out.println(myThread.getState());
    }
}
